<?php

namespace app\index\controller;

use app\common\controller\Frontend;
use app\common\model\TestDyznAnswer;
use app\common\model\TestHldAnswer;
use app\common\model\TestMbtiAnswer;
use app\common\model\TestZymAnswer;
use think\Db;

class Index extends Frontend
{

    protected $noNeedLogin = '*';
    protected $noNeedRight = '*';
    protected $layout = 'default';

    public function index()
    {
        echo "<script>location.href='index/user/login'</script>";
        die();
        $userId = $this -> auth -> id;
        if(!is_null($userId)){
            $dyzn = TestDyznAnswer::get(['user_id'=>$userId]);
            $mbti = TestMbtiAnswer::get(['user_id'=>$userId]);
            $hld = TestHldAnswer::get(['user_id'=>$userId]);
            $zym = TestZymAnswer::get(['user_id'=>$userId]);
        }else{
            $zym = $dyzn = $mbti = $hld = null;
        }

        $data = Db::query("
            select (select count(*) from fa_test_hld_answer) as hldcount ,(select count(*) from fa_test_dyzn_answer) as dyzncount,(select count(*) from fa_test_zym_answer) as zymcount ,(select count(*) from fa_test_mbti_answer) as mbticount limit 1
        ");
        $this -> assign('data',$data[0]);
        $this -> assign('zym',$zym);
        $this -> assign('dyzn',$dyzn);
        $this -> assign('hld',$hld);
        $this -> assign('mbti',$mbti);
        $this -> assign('isAuth',$userId);

        return $this->view->fetch();
    }

}
